public class ExampleEventHandling extends java.applet.Applet implements java.awt.event.MouseListener {

    StringBuffer strBuffer;

    @Override
    public void init() {
        super.init();
        addMouseListener(this);
        strBuffer = new StringBuffer();
        addItem("initializing the applet ");


    }

    @Override
    public void start() {
        addItem("starting the applet ");
    }

    @Override
    public void stop() {
        addItem("stopping the applet ");
    }

    @Override
    public void destroy() {
        addItem("unloading the applet");
    }


    void addItem(String word) {
        System.out.println(word);
        strBuffer.append(word);
        repaint();
    }


    @Override
    public void paint(java.awt.Graphics g) {
        super.paint(g);
        //Draw a Rectangle around the applet's display area.
        g.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
        //display the string inside the rectangle.
        g.drawString(strBuffer.toString(), 10, 20);
    }

    /**
     * @param e
     */
    @Override
    public void mouseClicked(java.awt.event.MouseEvent e) {
        addItem("mouse clicked! ");
    }

    /**
     * @param e
     */
    @Override
    public void mousePressed(java.awt.event.MouseEvent e) {

    }

    /**
     * @param e
     */
    @Override
    public void mouseReleased(java.awt.event.MouseEvent e) {

    }

    /**
     * @param e
     */
    @Override
    public void mouseEntered(java.awt.event.MouseEvent e) {

    }

    /**
     * @param e
     */
    @Override
    public void mouseExited(java.awt.event.MouseEvent e) {

    }
}
